﻿namespace HuwmanCode.Diagnostics.Logging

open System
open System.Globalization
open System.Transactions
open System.Runtime.Serialization
open System.Reflection
open HuwmanCode
open HuwmanCode.Transactions
open HuwmanCode.Diagnostics

/// <summary>
/// The trace event writer
/// </summary>
type public TraceEventWriter() = 
    interface ILogWriter with
        /// <summary>
        /// Writes to the event trace
        /// </summary>
        member this.Write message =
            match message.Level with
            | TraceLevel.Debug -> System.Diagnostics.Trace.TraceInformation(message.ToString())
            | TraceLevel.Info  -> System.Diagnostics.Trace.TraceInformation(message.ToString())
            | TraceLevel.Warn  -> System.Diagnostics.Trace.TraceWarning(message.ToString())
            | TraceLevel.Error -> System.Diagnostics.Trace.TraceError(message.ToString())
            | TraceLevel.Fatal -> System.Diagnostics.Trace.TraceError(message.ToString())
            | _ -> failwith "Unsupported trace level!"

    interface IDisposable with
        member this.Dispose () =
            ()